package blazingbubble.legacy.game.graphics;

import spark.graphics.Texture;
import spark.graphics.Renderer;
import spark.exception.LoadingException;
import spark.math.Vector3;

import java.io.File;

import javax.media.opengl.glu.GLU;
import javax.media.opengl.glu.GLUquadric;

import blazingbubble.legacy.game.Cannon;

public class CannonRenderer
{
	private GLUquadric sphere;
	private Texture bubbleTexture;

	public CannonRenderer()
	{
		sphere = Renderer.getInstance().getGlu().gluNewQuadric();
		Renderer.getInstance().getGlu().gluQuadricNormals(sphere, GLU.GLU_SMOOTH);
		Renderer.getInstance().getGlu().gluQuadricTexture(sphere, true);
	}

	public void initializeWithTestLooks() throws LoadingException
	{
		bubbleTexture = Texture.newTexture(new File(BubbleRenderer.RESOURCES_PATH + "graphics/fb/test/green.jpg"), true);
	}

	public void render(Cannon cannon, Vector3 offset)
	{
		bubbleTexture.bind();
		Renderer.getInstance().getGl().glPushMatrix();
		Vector3 target = cannon.getShootingDirection();
		Renderer.getInstance().getGl().glTranslatef(target.x + offset.x, target.y + offset.y, offset.z);

		Renderer.getInstance().getGlu().gluSphere(sphere,0.5f,32,32);

		Renderer.getInstance().getGl().glPopMatrix();
	}
}
